package org.mog.user.service.impl;

import dto.UserInsertDTO;
import dto.UserUpdateDTO;
import entity.pojo.User;
import lombok.RequiredArgsConstructor;
import org.mog.user.mapper.UserMapper;
import org.mog.user.service.IUserService;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class UserService implements IUserService {
    private final UserMapper userMapper;

    /**
     * 查询用户信息
     *
     * @return
     */
    @Override
    public User getByOpenId(String openId) {
        return userMapper.getByOpenId(openId);
    }

    /**
     * 新增用户
     *
     * @param userInsertDTO
     * @return
     */
    @Override
    public User insert(UserInsertDTO userInsertDTO) {
        userMapper.insert(userInsertDTO);
        return User.builder().id(userInsertDTO.getId()).build();
    }

    /**
     * 修改用户信息
     *
     * @param userUpdateDTO
     */
    @Override
    public void update(UserUpdateDTO userUpdateDTO) {
        userMapper.update(userUpdateDTO);
    }
}
